import React from "react"
import PubSub from "pubsub-js"
import "./Item.css"
export default function Item(props) {
  const { todo } = props
  function handle(e) {
    PubSub.publish("update", todo.id)
  }
  return (
    <li>
      <label>
        <input type="checkbox" checked={todo.isDone} onChange={handle} />
        <span className={todo.isDone ? "active" : ""}>{todo.todoName}</span>
      </label>
      <button className="btn btn-danger">删除</button>
      <button className="btn btn-danger btn-edit">修改</button>
    </li>
  )
}
